﻿using Microsoft.Extensions.Configuration;

namespace EPlantApp.Infrastructure
{
    public class AppSettings
    {
        static IConfiguration Configuration { get; set; }
        public AppSettings(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        /// <summary>
        /// 获取配置节点并转换成指定类型
        /// </summary>
        /// <typeparam name="T">节点类型</typeparam>
        /// <param name="key">节点路径</param>
        /// <returns>节点类型实例</returns>
        public static T Get<T>(string key)
        {
            return Configuration.GetSection(key).Get<T>();
        }

    }
}
